#!/bin/sh
# postinst script for openmediavault-mysql
#
# $Id: postinst 29 2011-11-15 13:32:30Z imooreyahoo@gmail.com $
#
# see: dh_installdeb(1)

set -e

. /etc/default/openmediavault
. /usr/share/openmediavault/scripts/helper-functions

case "$1" in
    configure)

	# Check for XML config
    if ! omv_config_exists "//services/mysql"; then
		omv_config_add_element "//services" "mysql" ""
		omv_config_add_element "//services/mysql" "enable" "0"
		omv_config_add_element "//services/mysql" "enable-networking" "1"
		omv_config_add_element "//services/mysql" "enable-phpmyadmin" "0"
		omv_config_add_element "//services/mysql" "extraoptions" ""
		omv_config_add_element "//services/mysql" "port" "3306"
		omv_config_add_element "//services/mysql" "bindaddress" "0.0.0.0"
		omv_config_add_element "//services/mysql" "password" ""
		omv_config_add_element "//services/mysql" "data-root" ""
		omv_config_add_element "//services/mysql" "mntentref" ""
	fi
	
	if ! omv_config_exists "//services/mysql/bindaddress"; then
		omv_config_add_element "//services/mysql" "bindaddress" "0.0.0.0"
	fi

	# Fix permissions
	omv_install_fixperms

    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
